package labilabyrinth.serializable;

import java.io.Serializable;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.RectF;

public class DeadlyHole extends Hole implements Serializable{
	
	/**
	 * reprezentuje dieru do ktorej gulicka nesmie vojst
	 */
	private static final long serialVersionUID = 1L;
	protected int diameter;
	protected int drawSize;
	protected MyPointF center;
	protected MyRectF touchableRect;
	
	public MyPointF getCenter() {
		return this.center;
	}
	
	public DeadlyHole(int size,float centerX, float centerY){
		float d = 2;
		this.diameter = size / 2;
		this.drawSize = (size+4);
		this.center = new MyPointF(centerX,centerY);
		this.touchableRect = new MyRectF(center.x-(diameter-d), center.y-(diameter-d), center.x+(diameter-d), center.y+(diameter-d));
	}
	
	public  void draw(Canvas c, Bitmap bmp){
		Paint paint = new Paint();
		paint.setColor(color);
		c.drawCircle((center.x)+2, (center.y)+2, (drawSize/2)+1, paint);
		c.drawBitmap(bmp,(center.x)-diameter,(center.y)-diameter,paint);
	}
	
	/*
	 * dostane bod a pozrie ci vzdialenost tohto bodu je mensia
	 * ako polovica polomeru diery ak ano tak vrati referenciu na seba
	 * ak nie tak null
	 */
	public DeadlyHole isInHole(PointF center){
		RectF tRect = new RectF(touchableRect.left,touchableRect.top,touchableRect.right,touchableRect.bottom);
		if(tRect.contains(center.x,center.y))
			return this;
		else
			return null;
	}


}

